import { createApp } from 'vue';
import App from './App.vue';
import { createPinia } from 'pinia';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
import router from '@/router';

const app = createApp(App);

// 1️⃣ 创建 Pinia 实例
const pinia = createPinia();

// 2️⃣ 注册持久化插件
pinia.use(piniaPluginPersistedstate);

// 3️⃣ 挂载 Pinia
app.use(pinia);

// 4️⃣ 挂载 ElementPlus
app.use(ElementPlus);

// 5️⃣ 全局注册 ElementPlus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

// 6️⃣ 挂载路由
app.use(router);

app.mount('#app');
